package com.yunhe.abnormal.repository.base;

import com.yunhe.abnormal.domain.base.AlarmNotifyConfig;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * 异常通知配置数据仓库
 * @author liuronglei
 */
@Repository
public interface AlarmNotifyConfigRepository extends Neo4jRepository<AlarmNotifyConfig, Long> {

    @Query("match(anc:AlarmNotifyConfig)-[r:STATION_OF]->(s:Station) where ID(anc)={id} delete r return anc")
    void unbindStation(@Param("id") Long id);

    @Query("match(anc:AlarmNotifyConfig),(s:Station) where ID(anc)={id} and ID(s)={stationId}" +
            " create (anc)-[r:STATION_OF]->(s) return anc")
    void bindStation(@Param("id") Long id, @Param("stationId") Long stationId);
}
